package edu.hubu.talentmanagementsystem.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import edu.hubu.talentmanagementsystem.model.ext.CompanyRecruitment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

@Mapper
public interface CompanyRecruitmentMapper extends BaseMapper<CompanyRecruitment> {
    int insert(CompanyRecruitment entity);

    int deleteById(Serializable id);

    int deleteByMap(@Param("cm") Map<String, Object> columnMap);

    int delete(@Param("ew") Wrapper<CompanyRecruitment> queryWrapper);

    int deleteBatchIds(@Param("coll") Collection<? extends Serializable> idList);

    int updateById(@Param("et") CompanyRecruitment entity);

    int update(@Param("et") CompanyRecruitment entity, @Param("ew") Wrapper<CompanyRecruitment> updateWrapper);

    CompanyRecruitment selectById(Serializable id);

    List<CompanyRecruitment> selectBatchIds(@Param("coll") Collection<? extends Serializable> idList);

    List<CompanyRecruitment> selectByMap(@Param("cm") Map<String, Object> columnMap);

    CompanyRecruitment selectOne(@Param("ew") Wrapper<CompanyRecruitment> queryWrapper);

    Integer selectCount(@Param("ew") Wrapper<CompanyRecruitment> queryWrapper);

    List<CompanyRecruitment> selectList(@Param("ew") Wrapper<CompanyRecruitment> queryWrapper);

    List<Map<String, Object>> selectMaps(@Param("ew") Wrapper<CompanyRecruitment> queryWrapper);

    List<Object> selectObjs(@Param("ew") Wrapper<CompanyRecruitment> queryWrapper);

    <E extends IPage<CompanyRecruitment>> E selectPage(E page, @Param("ew") Wrapper<CompanyRecruitment> queryWrapper);

    <E extends IPage<Map<String, Object>>> E selectMapsPage(E page, @Param("ew") Wrapper<CompanyRecruitment> queryWrapper);

    @Select("select * from company_recruitment where company_recruitment_id in " +
            "(select company_recruitment_id from position_small_tag_company_recruitment " +
            "where position_small_tag_id = #{positionSmallTagId})")
    @Results({
            @Result(column = "company_recruitment_work_type_id",property = "workType",
                one = @One(select = "edu.hubu.talentmanagementsystem.mapper.WorkTypeMapper.selectById")),
            @Result(column = "company_recruitment_educational_degree_id",property = "educationalDegree",
                one = @One(select = "edu.hubu.talentmanagementsystem.mapper.EducationalDegreeMapper.selectById"))
    })
    List<CompanyRecruitment> pagingQueryCompanyRecruitmentByPositionSmallTagId(Page<CompanyRecruitment> page,@Param("positionSmallTagId") Integer positionSmallTagId);

}